import { __values } from "_tslib@1.10.0@tslib"

// 明星
let star = {
  name: '张XX',
  age: 25,
  phone: 'star: 13900001111'
}

// 经纪人
let agent = new Proxy(star, {
  get: function (target, key) {
    if (key === 'phone') {
      // 返回经济人自己的电话
      return 'agent: 16899997777'
    }
    if (key === 'price') {
      // 明星不报价，经济人报价
      return 120000
    }
    return target[key]
  },
  set: function (target, key, val) {
    if (key === 'customPrice') {
      if (val < 100000) {
        // 最低 10w
        throw new Error('价格太低')
      } else {
        target[key] = val
        return true
      }
    }
  }
})


// test
console.log(agent.name)
console.log(agent.aget)
console.log(agent.phone)
console.log(agent.price)

agent.customPrice = 150000
console.log('agent.customPrice', agent.customPrice)